package Ventanas;

import javax.swing.JFrame;
import javax.swing.JButton;

import fiuba.algo3.tp2.Mapa;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;

public class GrillaMapa {

	JFrame frame = new JFrame();
	JButton[][] grid;
	
	public GrillaMapa(int width, int length){
		
		frame.setLayout(new GridLayout(width,length));
		grid = new JButton[width][length];
		for(int x=0;x<length;x++){
			for(int y=0;y<width;y++){
				grid[x][y] = new JButton("("+x+","+y+")");
				frame.add(grid[x][y]);
			}
		}
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);

	}
	
	   public void actionPerformed(ActionEvent e) {
	        
	    Mapa mapa = Mapa.getInstance();
	    System.out.println("Button pressed: " + e.getActionCommand());
	    ((JButton)e.getSource()).setEnabled(false);
	    	
	    }
	
	public static void main(String [] args){
		new GrillaMapa(12,12);
	}
	
}
